<?php
namespace Home\Controller;
use Think\Controller;
class RegisterController extends Controller {
    public function index(){
      
      $this->display();
    }
    
   public function register(){
   	$m=D('User');
   	$data['password']=$_POST['password'];
   	$data['username']=$_POST['username'];
    //$data['_logic']='or';
    $result=$m->where($data)->count();
    $data['id']=$m->max('id')+1;
    if($result>0){
    	$this->error('该用户已存在','index',1);
    } else{
    	  $res=$m->add($data);
    	   if ($res>0)
         {
          $this->success('注册成功','index',1) ;
         }
        else{
          $this->error('注册失败','index',1) ;
         
            }
    
          }

     echo $m->getLastSql();
   }

   
}